package com.example.demo.mapper;

import com.example.demo.entity.UpdateInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AndroidVersionMapper {
    @Select("SELECT a.* ,IF(SUM(ac.`forced_update`)>0,TRUE,FALSE) AS is_forced \n" +
            "FROM android_version AS a\n" +
            "LEFT JOIN android_version AS ac ON ac.`version_code`> #{versionCode} \n" +
            "WHERE a.version_code = (SELECT MAX(version_code)  FROM android_version  )\n" +
            "AND a.version_code > #{versionCode}  GROUP by a.id")
    UpdateInfo findUpdateInfoByVersionCode( Integer versionCode );
}